package com.mas.common;

import com.mas.monitor.MonitorResourceAgent;
import com.mas.session.Session;
import com.mas.strategey.Proposal;
import com.thoughtworks.xstream.XStream;

import jade.core.Agent;

public class AgentUtil {

	public static void logInfo(Session session, String message) {
		System.out.println("###" + session.getName() + "-->" + message);
	}

	public static void logInfo(Agent agent, String message) {
		System.out.println("###" + agent.getName() + "-->" + message);

	}

	public static void debug(Agent agent, String message) {
		if (Consts.DebugMode) {
			System.out.println("###" + agent.getName() + "-->" + message);
		}

	}


	public static Proposal readProposal(String msgContent) {
		XStream xstream = new XStream();
		Object obj = null;
		try {
			obj = xstream.fromXML(msgContent);
		} catch (Exception e) {
			return null;
		}
		if (!(obj instanceof Proposal)) {
			return null;
		}
		return (Proposal) obj;
	}

	public static boolean isAgentMonitor(Agent agent) {
		if (agent instanceof MonitorResourceAgent) {
			return true;
		}
		return false;
	}

}
